<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::namespace('App\Http\Controllers')->group(function (){
    /** 用户授权登录*/
    Route::any('auth/login', 'AuthController@login');

    Route::apiResource('banner','BannerController');

    Route::apiResource('category', 'CategoryController');

    Route::apiResource('tags', 'TagController');

    Route::apiResource('config', 'ConfigController');

    Route::get('addview/{id}', 'CoverController@addview');

    Route::post('search_cover', 'CoverController@search_cover');

    Route::get('index', 'HomeController@index');
    Route::get('indes', 'HomeController@indes');

    Route::post('upload','HomeController@upload');

});

Route::group([
    'middleware' => 'auth:sanctum',
    'namespace'  => 'App\Http\Controllers'
],function (){

    Route::apiResource('zan', 'ZanController');
    Route::get('is_zan', 'ZanController@is_zan');

    Route::apiResource('coll', 'CollController');
    Route::get('is_coll', 'CollController@is_coll');

    Route::apiResource('record', 'RecordController');

    Route::apiResource('cover', 'CoverController');

    Route::apiResource('design', 'DesignController');

    Route::get('feed', function () {
        $json = json_decode(file_get_contents(public_path('db_init.json')), true);
        return json_encode($json['wx_feed']);
    });

    Route::apiResource('download','DownloadController');

    Route::apiResource('user','UserController');

    // 用户观看完视频后增加积分等操作
    Route::post('user_integral','UserController@user_integral');

    // 用户签到操作
    Route::apiResource('sign','SignController');

    // 获取所有用户列表
    Route::get('user_list','UserController@user_list');



    Route::get('covers','CoverController@covers');
    Route::put('covers/{id}','CoverController@examine');

});

Route::namespace('App\Http\Controllers')->group(function (){

    Route::get('user_count','UserController@count');
    Route::get('cover_count','CoverController@count');
    Route::get('download_count','DownloadController@count');

});

